package com.csce.domain.entity.go_score;

import com.csce.domain.entity.go_score.dto.GoScoreExamPlaceDto;
import com.doudou.core.container.ListUtil;
import com.osce.common.annotation.Excel;
import com.osce.common.core.entity.BaseEntity;
import lombok.*;

import java.util.List;

/**
 * 妇产科考试-考场对象 go_score_exam_place
 *
 * @author zzx
 * @since 2024-05-17
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
@ToString
@EqualsAndHashCode(callSuper = true)
public class GoScoreExamPlace extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    private Long id;

    /**
     * 考试编号
     */
    @Excel(name = "考试编号")
    private Long examId;

    /**
     * 考站编号
     */
    @Excel(name = "考站编号")
    private Long placeId;

    /**
     * 教师编号集合
     */
    @Excel(name = "教师编号集合")
    private String teacherIds;

    /**
     * 技能编号
     */
    @Excel(name = "技能编号")
    private Long skillId;

    /**
     * 评分表集合
     */
    @Excel(name = "评分表集合")
    private String sheetIds;

    private List<GoScoreExamStudent> goScoreExamStudentList;

    public List<Long> getTeacherIdList(){
        return ListUtil.listBySimpleStr(this.teacherIds,",",Long.class);
    }

    public List<Long> getSheetIdList(){
        return ListUtil.listBySimpleStr(this.sheetIds,",",Long.class);
    }

    public List<Long> getUserIdList(){
        List<Long> userIdList = ListUtil.linkedList();
        if (ListUtil.isNotEmpty(this.goScoreExamStudentList)){
            for (GoScoreExamStudent goScoreExamStudent : this.goScoreExamStudentList) {
                userIdList.add(goScoreExamStudent.getUserId());
            }
        }
        return userIdList;
    }


    public GoScoreExamPlaceDto convertGoScoreExamPlaceDto(){
        GoScoreExamPlaceDto goScoreExamPlaceDto = new GoScoreExamPlaceDto();
        goScoreExamPlaceDto.setId(this.id);
        goScoreExamPlaceDto.setExamId(this.examId);
        goScoreExamPlaceDto.setPlaceId(this.placeId);
        goScoreExamPlaceDto.setTeacherIds(this.getTeacherIdList());
        goScoreExamPlaceDto.setSkillId(this.skillId);
        goScoreExamPlaceDto.setSheetIds(this.getSheetIdList());
        goScoreExamPlaceDto.setStudentIdList(this.getUserIdList());
        return goScoreExamPlaceDto;
    }

}
